home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Education / xModels 2D and 3D / Tutorial Examples / Tutorial 9. Lathe and Extrude < prev   
Encoding:
Text File  |  1995-06-22  |  2.6 KB  |  71 lines  |  [TEXT/X_#a]

  1. ; Tutorial 9: Lathing and Extrusion
  2.  
  3.         animate 30 30
  4.  
  5. ; Modeling real objects (like cars or faces) in 3D requires
  6. ; that they be approximated with large numbers of polygons,
  7. ; perhaps thousands of polygons per object.  You won't want
  8. ; to do anything so complicated with xModels-3D.  But it
  9. ; does have two ways of producing fairly complex, but also
  10. ; fairly regular, objects.  The methods are called lathing
  11. ; and extrusion.  The idea is to take a figure consisting
  12. ; of a connected sequence of line segments in the xy-plane.
  13. ; (For extrusion, a polygon is used; for lathing, however,
  14. ; the final point is not automatically connected back
  15. ; to the first).  Some specified number of copies of this
  16. ; figure are made and then more line segments are added to
  17. ; connect  corresponding endpoints in the copies.  This is
  18. ; not as complicated as it sounds.
  19. ;
  20. ; In lathing, the copies are made by rotating the original
  21. ; figure about the y-axis.  The command for doing lathing
  22. ; is "lathe":
  23.  
  24.       lathe 8  ; The first parameter is the number of copies,
  25.          0,5 1,1 3,0 1,-1 0,-5  ; then the list of points.
  26.          yrotate 0::45  ; You can apply transformations
  27.                         ; to lathed objects, of course.
  28.  
  29. ; Compare the figure produced by the above to the polygon
  30. ; made with the same points:
  31.  
  32.       polygon 0,5 1,1 3,0 1,-1 0,-5
  33.          xtranslate 5  ; move it over so you can see it
  34.  
  35. ; The extra vertical line from (0,-5) back to (0,5), which
  36. ; is added to close the polygon, is not used in the lathing
  37. ; operation.  The remaining sides form the figure that is
  38. ; rotated about the y-axis by the lathe command.
  39. ;
  40. ; Here are more examples:
  41.  
  42.       lathe 20 2,2 2,-2  ; Lathing a single line.
  43.          xrotate 0::180 ; Tumble it end-over-end
  44.          xtranslate -7
  45.  
  46.       lathe 4  2,2:-2:2  3,0 ; You can use animation!
  47.          translate -4,7,0
  48.  
  49. ; Extrusion is not quite so interesting as lathing.  In
  50. ; extrusion, the copies of the original figure are made
  51. ; by translating the original in the z-direction, instead
  52. ; of by rotating it.  The copies are spaced one unit apart, 
  53. ; although you can change that, of course, by scaling
  54. ; in the z direction.  The extruded figure entends
  55. ; equally far behind the xy-plane as it does in front
  56. ; of it.  The command for doing extrusion is "extrude".
  57. ; Here, for example, is a 3D "E":
  58.  
  59.       extrude 2 ; The number of copies.
  60.            0,0 0,5 3,5 3,4 1,4 1,3    ; List of points.
  61.            2,3 2,2 1,2 1,1 3,1 3,0 
  62.         translate -7.5,-9.5,0
  63.  
  64. ; And here is an example that rotates so you can see
  65. ; it better:
  66.  
  67.      extrude 5 -2,-2 0,2 2,-2  ; Extrude 5 copies of
  68.        yrotate -30:30:-30      ;            a triangle
  69.        translate 3,-6.5,0
  70.  
  71.